/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.isn.historiaclinica.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author pool
 */
@Entity
@Table(name = "provincia")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Provincia.findAll", query = "SELECT p FROM Provincia p"),
    @NamedQuery(name = "Provincia.findByCodProv", query = "SELECT p FROM Provincia p WHERE p.provinciaPK.codProv = :codProv"),
    @NamedQuery(name = "Provincia.findByDescProv", query = "SELECT p FROM Provincia p WHERE p.descProv = :descProv"),
    @NamedQuery(name = "Provincia.findByCodDepa", query = "SELECT p FROM Provincia p WHERE p.provinciaPK.codDepa = :codDepa")})
public class Provincia implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected ProvinciaPK provinciaPK;
    @Column(name = "Desc_Prov")
    private String descProv;
    @JoinColumn(name = "Cod_Depa", referencedColumnName = "Cod_Depa", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Departamento departamento;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "provincia")
    private Collection<Distrito> distritoCollection;
    /*
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codProv")
    private Collection<HistoriaClinica> historiaClinicaCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codProv")
    private Collection<AnimalMordedor> animalMordedorCollection;*/
    public Provincia() {
    }
    
    public Provincia(ProvinciaPK provinciaPK) {
        this.provinciaPK = provinciaPK;
    }

    public Provincia(String codProv, String codDepa) {
        this.provinciaPK = new ProvinciaPK(codProv, codDepa);
    }
    
    public ProvinciaPK getProvinciaPK() {
        return provinciaPK;
    }

    public void setProvinciaPK(ProvinciaPK provinciaPK) {
        this.provinciaPK = provinciaPK;
    }
    
    
	public String getDescProv() {
        return descProv;
    }

    public void setDescProv(String descProv) {
        this.descProv = descProv;
    }

    public Departamento getDepartamento() {
        return departamento;
    }

    public void setDepartamento(Departamento departamento) {
        this.departamento = departamento;
    }
/*
    @XmlTransient
    public Collection<AnimalMordedor> getAnimalMordedorCollection() {
        return animalMordedorCollection;
    }

    public void setAnimalMordedorCollection(Collection<AnimalMordedor> animalMordedorCollection) {
        this.animalMordedorCollection = animalMordedorCollection;
    }
*/
    @XmlTransient
    public Collection<Distrito> getDistritoCollection() {
        return distritoCollection;
    }

    public void setDistritoCollection(Collection<Distrito> distritoCollection) {
        this.distritoCollection = distritoCollection;
    }
/*
    @XmlTransient
    public Collection<HistoriaClinica> getHistoriaClinicaCollection() {
        return historiaClinicaCollection;
    }

    public void setHistoriaClinicaCollection(Collection<HistoriaClinica> historiaClinicaCollection) {
        this.historiaClinicaCollection = historiaClinicaCollection;
    }
*/
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (provinciaPK != null ? provinciaPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Provincia)) {
            return false;
        }
        Provincia other = (Provincia) object;
        if ((this.provinciaPK == null && other.provinciaPK != null) || (this.provinciaPK != null && !this.provinciaPK.equals(other.provinciaPK))) {
            return false;
        }
        return true;
    }
    
}
